//
// Created by Jisam on 13/10/2024 19:53.
// Solution of  b
#include <bits/stdc++.h>

#define  int long long
#define  endl "\n"
#define  all(x) (x).begin(),(x).end()
#define  pb push_back
using namespace std;


signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int,int> mp;
    for (int i = 0; i < n; i++) cin >> a[i];
    int cur = 0;
    int ans = 0;
    for(int i = 0 ; i < n ; i ++){
        while(cur < 3){
            mp[a[i]] ++;
            cur ++;
            continue;
        }
        int ok = 0;
        int cnt = 0,ji = 0,ou = 0;
        for(auto [x,y] : mp){
            cnt += y;
            if(y % 2 == 0){
                ou ++;
            }else{
                ji ++;
            }
        }
        for(int j = 0 ; j < i/2 ; j++){
            if(a[j] != a[i - j - 1]){
                ok = 1;
            }
        }
        if(ji <= 3 && ok == 1){
            ans ++;
        }
        mp[cur]--;
        cur --;
    }
    cout << ans << endl;
    return 0;
}